package mae.app;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
/**
 * Class for the creation and updating of the Depression Glass Table
 * @author DJ
 *
 */
public class DepressionGlassTable {
	// Database creation SQL statement
	private static final String DATABASE_CREATE = "create table DepressionGlass "
			+ "(_id integer primary key autoincrement, "
			+ "Pattern text not null, "
			+ "Color text not null, "
			+ "Piece text not null, "
			+ "Value text not null, "
			+ "Quantity text not null, " + "Condition text not null);";

	/**
	 * Creation method for the Depression Glass table which executes the 
	 * DATABASE_CREATE string.
	 * @param database // an SQLite Database
	 */
	public static void onCreate(SQLiteDatabase database) {
		database.execSQL(DATABASE_CREATE);
	}

	/**
	 * Updating method for the Depression Glass table which will drop
	 * the DepressionGlass table if exists. Then calls the onCreate method
	 * @param database // an SQLite database
	 * @param oldVersion // an int describing the oldVersion of database
	 * @param newVersion // and int descriving the newVersion of database
	 */
	public static void onUpgrade(SQLiteDatabase database, int oldVersion,
			int newVersion) {
		Log.w(DepressionGlassTable.class.getName(),
				"Upgrading database from version " + oldVersion + " to "
						+ newVersion + ", which will destroy all old data");
		database.execSQL("DROP TABLE IF EXISTS DepressionGlass");
		onCreate(database);
	}
}